package com.zy.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zy.mapper.MxMapper;
import com.zy.pojo.Mx;
import com.zy.service.MxService;
import com.zy.vo.ManagementVo;
import com.zy.vo.MX.MxVo;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;
@Service("mxService")
public class MxServiceImpl extends ServiceImpl<MxMapper, Mx> implements MxService {
    @Resource
    private MxMapper mxMapper;
    @Override
    public List<Mx> getmxList() {
        return mxMapper.selectList(null);
    }

    @Override
    public void add(Mx mx) {
        mxMapper.insert(mx);
    }

    @Override
    public void select(Integer id) {
        mxMapper.selectById(id);
    }

    @Override
    public void del(Integer id) {
        mxMapper.deleteById(id);
    }

    @Override
    public MxVo getPage(Integer pageNo, Integer pageSize, ManagementVo managementVo) {
        Page page =new Page();
        page.setSize(pageSize);
        page.setCurrent(pageNo);
        QueryWrapper queryWrapper =new QueryWrapper();
        queryWrapper.like(!StringUtils.isEmpty(managementVo.getUserCode()),"mx_lingcode",managementVo.getUserCode());

        List<Mx> list =mxMapper.getMxList(page,queryWrapper);
        return new MxVo(list,page.getTotal());
    }

    @Override
    public void getMxHoused(Mx mx) {
        mxMapper.getMxHoused(mx);
    }


}
